package com.htpcremote;

import android.R.drawable;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class BaseActivity extends Activity {
	public static final int MENU_PREFS = 0;
	public static final int MENU_HELP = 1;
	private HelpDialog dlHelp;
	
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		if (this.dlHelp == null) {
			this.dlHelp = new HelpDialog(this);
		}
	}
	
	// menu
	public boolean onCreateOptionsMenu(Menu menu) {
		super.onCreateOptionsMenu(menu);
		//
		menu.add(0, MENU_PREFS, 0, R.string.txt_preferences).setShortcut('0', 'p').setIcon(drawable.ic_menu_preferences);
		menu.add(0, MENU_HELP, 0, R.string.txt_help).setShortcut('1', 'h').setIcon(drawable.ic_menu_help);
		//
		return true;
	}

	public boolean onOptionsItemSelected(MenuItem item) {
		//
		switch (item.getItemId()) {
		case MENU_PREFS:
			//
			this.onPrefs();
			break;
		case MENU_HELP:
			//
			this.onHelp();
			break;
		}
		//
		return super.onOptionsItemSelected(item);
	}
	
	private void onHelp() {
		this.dlHelp.show();
	}

	private void onPrefs() {
		Intent i = new Intent(this, PrefsActivity.class);
		this.startActivity(i);
	}
}
